
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<style>
	#treeDiv .modal-dialog{
		margin: 50px auto;
	}
	.btn-warning.btn-outline {
		color: #fff;
	}
	.btn-submit{
		background: #2c74fa;
		margin-left: 20px;
		border: none;
		color: #fff;
	}
</style>
<div class="modal" id="treeDiv1" tabindex="-1" role="dialog" aria-hidden="true" style="width: auto;">

	<div class="modal-dialog modal-lg" role="document">

		<div class="modal-content animated bounceInRight">
			<div class="modal-body" style="padding-bottom: 20px; padding-top: 5px;">
				
				<div class="col-sm-12">
					<c:import url="/web/mdMaterialCategory/getMdMaterialCategoryTreeByOutput" charEncoding="utf-8"></c:import>

				</div>


				<div class="col-md-12">
					<div class="form-group row m-b-none">
						<div class="col-sm-10 col-sm-offset-2 text-right">
							<button class="btn btn-white btn-lg" type="button" data-dismiss="modal">返回</button>
							<button id="selectButton" class="btn btn-submit" data-style="expand-right">确定</button>
						</div>
					</div>
				</div>

			</div>

		</div>

	</div>

</div>

<script>
	$(document).ready(function() {
		//确认按钮
		$("#selectButton").click(function(){
			var nodeId = getTreeSelectNodeId();
			var nodeType = getTreeSelectNodeType();
			if(nodeId==""){
				redragonJS.alert("必须选择一个类型");
			}else if(nodeType=="root"){
				redragonJS.alert("不能选择根节点");
			}else{
				$('#treeDiv1').modal('hide');
				$.ajax({
					type: "post",
					url: "web/mdMaterialCategory/getMdMaterialCategory",
					data: {"categoryId": nodeId},
					async: false,
					dataType: "json",
					cache: false,
					success: function(data){
						if(data!=""){
							var categoryCode = data.categoryCode;
							var categoryName = data.categoryName;
							var segmentCode = data.segmentCode;
							var segmentDesc = data.segmentDesc;
							var newMaterialCode = data.newMaterialCode;
							$("#categoryDesc").val(segmentDesc);
							$("#categoryCode").val(categoryCode);
							$("#materialCode").val(newMaterialCode);
						}
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						redragonJS.alert(textStatus);
					}
				});
			}
		});
	});
</script>
